# Just a log helper
window.log = (args...) ->
    console.log.apply console, args if console.log?
     
window.myapp = new Backbone.Marionette.Application()
myapp.addRegions
    mainRegion: "#main"
    navRegion: "#nav_bar"
myapp.vent.on "routing:started", =>
    Backbone.history.start() if !Backbone.History.started

# ------------------------------------- INIT APP
$ -> # document is ready!
    myapp.start()
    $.datepicker.regional['zh-CN'] = {
        closeText: "关闭"
        prevText: "上一月"
        nextText: '下一月', # Display text for next month link
        currentText: '今天', # Display text for current month link
        monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'], # Names of months for drop-down and formatting
        monthNamesShort: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'], # For formatting
        dayNames: ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], # For formatting
        dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], # For formatting
        dayNamesMin: ['日','一','二','三','四','五','六'], # Column headings for days starting at Sunday
        weekHeader: '星期', # Column header for week of the year
        dateFormat: 'yy-mm-dd', # See format options on parseDate
        firstDay: 1, # The first day of the week, Sun = 0, Mon = 1, ...
        isRTL: false, # True if right-to-left language, false if left-to-right
        showMonthAfterYear: false, # True if the year select precedes month, false for month then year
        yearSuffix: '' # Additional text to append to the year in the month headers
        changeMonth: true
        changeYear: true
    };
    $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
    $.timepicker.regional['zh-CN'] = {
        timeText: '时间',
        hourText: '小时',
        minuteText: '分钟',
        secondText: '秒钟',
        millisecText: '微秒',
        timezoneText: '时区',
        currentText: '现在时间',
        closeText: '关闭',
        timeFormat: 'HH:mm:ss',
        amNames: ['AM', 'A'],
        pmNames: ['PM', 'P'],
        isRTL: false,
        #showButtonPanel: false
    };
    $.timepicker.setDefaults($.timepicker.regional['zh-CN']);
    
    requirejs.config({
            paths: {
                #jquery: '/assets/javascripts/jquery-1.7.2',
                #bootstrap: '/assets/javascripts/bootstrap',           
                util: '/assets/javascripts/fuelux-master/src/util',
                fuelux: '/assets/javascripts/fuelux-master/src'
            }
        });
        
    require(['jquery', 'fuelux/combobox'], ($) => 
        $('#myCombobox').combobox()
    )
        